VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmARCollection 
   BackColor       =   &H00F7D9C2&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   7290
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   8955
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   7290
   ScaleWidth      =   8955
   ShowInTaskbar   =   0   'False
   Begin MSComctlLib.StatusBar sbRS 
      Align           =   2  'Align Bottom
      Height          =   285
      Left            =   0
      TabIndex        =   7
      Top             =   7005
      Width           =   8955
      _ExtentX        =   15796
      _ExtentY        =   503
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   5
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            AutoSize        =   1
            Bevel           =   0
            Object.Width           =   2568
            MinWidth        =   2
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ITGControls.ComunionFrames ComunionFrames2 
      Height          =   4725
      Left            =   0
      Top             =   2085
      Width           =   8805
      _ExtentX        =   15531
      _ExtentY        =   8334
      FrameColor      =   4210752
      BackColor       =   16243138
      FillColor       =   16243138
      RoundedCorner   =   0   'False
      Caption         =   "Details"
      Alignment       =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ThemeColor      =   5
      ColorFrom       =   16243138
      ColorTo         =   16250865
      Begin ITGControls.ITGTab SSTab1 
         Height          =   2580
         Left            =   0
         TabIndex        =   10
         Top             =   435
         Width           =   8775
         _ExtentX        =   15478
         _ExtentY        =   4551
         TabCount        =   4
         TabCaption(0)   =   "Invoice"
         TabContCtrlCnt(0)=   1
         Tab(0)ContCtrlCap(1)=   "dtgInvoice"
         TabCaption(1)   =   "Payment"
         TabContCtrlCnt(1)=   2
         Tab(1)ContCtrlCap(1)=   "dtgPayment"
         Tab(1)ContCtrlCap(2)=   "cboPR_C"
         TabCaption(2)   =   "Others"
         TabContCtrlCnt(2)=   2
         Tab(2)ContCtrlCap(1)=   "dtgOthers"
         Tab(2)ContCtrlCap(2)=   "cboOthers"
         TabCaption(3)   =   "Application Payment"
         TabContCtrlCnt(3)=   3
         Tab(3)ContCtrlCap(1)=   "dtgMap"
         Tab(3)ContCtrlCap(2)=   "cmdMap"
         Tab(3)ContCtrlCap(3)=   "cmdClearMap"
         TabTheme        =   2
         ActiveTabBackStartColor=   16250865
         ActiveTabBackEndColor=   16243138
         InActiveTabBackStartColor=   16250865
         InActiveTabBackEndColor=   16243138
         BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         OuterBorderColor=   4210752
         TopLeftInnerBorderColor=   4210752
         BottomRightInnerBorderColor=   4210752
         DisabledTabBackColor=   16243138
         DisabledTabForeColor=   -2147483631
         Begin MSDataGridLib.DataGrid dtgInvoice 
            Height          =   2265
            Left            =   0
            TabIndex        =   18
            Top             =   315
            Width           =   8790
            _ExtentX        =   15505
            _ExtentY        =   3995
            _Version        =   393216
            AllowUpdate     =   -1  'True
            AllowArrows     =   -1  'True
            BackColor       =   16777215
            HeadLines       =   1
            RowHeight       =   15
            TabAcrossSplits =   -1  'True
            TabAction       =   2
            FormatLocked    =   -1  'True
            AllowDelete     =   -1  'True
            BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ColumnCount     =   6
            BeginProperty Column00 
               DataField       =   "cInvNo"
               Caption         =   "Invoice No."
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column01 
               DataField       =   "dInvDate"
               Caption         =   "Date"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "MM/dd/yyyy"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   3
               EndProperty
            EndProperty
            BeginProperty Column02 
               DataField       =   "nInvBalance"
               Caption         =   "Balance"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            BeginProperty Column03 
               DataField       =   "nApplied"
               Caption         =   "Applied"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            BeginProperty Column04 
               DataField       =   "nEWT"
               Caption         =   "EWT"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            BeginProperty Column05 
               DataField       =   "nEVAT"
               Caption         =   "EVAT"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            SplitCount      =   1
            BeginProperty Split0 
               BeginProperty Column00 
                  Button          =   -1  'True
                  ColumnWidth     =   1440
               EndProperty
               BeginProperty Column01 
                  Locked          =   -1  'True
                  ColumnWidth     =   1200.189
               EndProperty
               BeginProperty Column02 
                  Alignment       =   1
                  Locked          =   -1  'True
                  ColumnWidth     =   1319.811
               EndProperty
               BeginProperty Column03 
                  Alignment       =   1
                  ColumnWidth     =   1305.071
               EndProperty
               BeginProperty Column04 
                  Alignment       =   1
                  ColumnWidth     =   1214.929
               EndProperty
               BeginProperty Column05 
                  Alignment       =   1
                  ColumnWidth     =   1200.189
               EndProperty
            EndProperty
         End
         Begin MSDataGridLib.DataGrid dtgPayment 
            Height          =   2265
            Left            =   -75000
            TabIndex        =   17
            Top             =   315
            Width           =   8790
            _ExtentX        =   15505
            _ExtentY        =   3995
            _Version        =   393216
            AllowUpdate     =   -1  'True
            AllowArrows     =   -1  'True
            BackColor       =   16777215
            HeadLines       =   1
            RowHeight       =   15
            TabAcrossSplits =   -1  'True
            TabAction       =   2
            FormatLocked    =   -1  'True
            AllowDelete     =   -1  'True
            BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ColumnCount     =   5
            BeginProperty Column00 
               DataField       =   "cType"
               Caption         =   "Type"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column01 
               DataField       =   "cBankID"
               Caption         =   "Bank"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column02 
               DataField       =   "cCheckNo"
               Caption         =   "Check No."
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column03 
               DataField       =   "dCheckDate"
               Caption         =   "Date"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "MM/dd/yyyy"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   3
               EndProperty
            EndProperty
            BeginProperty Column04 
               DataField       =   "nAmount"
               Caption         =   "Amount"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            SplitCount      =   1
            BeginProperty Split0 
               BeginProperty Column00 
                  Button          =   -1  'True
                  Locked          =   -1  'True
                  ColumnWidth     =   1200.189
               EndProperty
               BeginProperty Column01 
                  Button          =   -1  'True
               EndProperty
               BeginProperty Column02 
                  ColumnWidth     =   2039.811
               EndProperty
               BeginProperty Column03 
                  ColumnWidth     =   1319.811
               EndProperty
               BeginProperty Column04 
                  Alignment       =   1
                  ColumnWidth     =   1604.976
               EndProperty
            EndProperty
         End
         Begin VB.ComboBox cboPR_C 
            Height          =   315
            ItemData        =   "frmARCollection.frx":0000
            Left            =   -74955
            List            =   "frmARCollection.frx":0002
            Style           =   2  'Dropdown List
            TabIndex        =   16
            Top             =   840
            Visible         =   0   'False
            Width           =   1515
         End
         Begin MSDataGridLib.DataGrid dtgOthers 
            Height          =   2265
            Left            =   -75000
            TabIndex        =   15
            Top             =   315
            Width           =   8790
            _ExtentX        =   15505
            _ExtentY        =   3995
            _Version        =   393216
            AllowUpdate     =   -1  'True
            AllowArrows     =   -1  'True
            BackColor       =   16777215
            HeadLines       =   1
            RowHeight       =   15
            TabAcrossSplits =   -1  'True
            TabAction       =   2
            FormatLocked    =   -1  'True
            AllowDelete     =   -1  'True
            BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ColumnCount     =   5
            BeginProperty Column00 
               DataField       =   "cType"
               Caption         =   "Type"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column01 
               DataField       =   "cAcctNo"
               Caption         =   "Account No."
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   "MM/dd/yyyy"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column02 
               DataField       =   "cTitle"
               Caption         =   "Account Title"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column03 
               DataField       =   "cDesc"
               Caption         =   "Description"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column04 
               DataField       =   "nAmount"
               Caption         =   "Amount"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            SplitCount      =   1
            BeginProperty Split0 
               BeginProperty Column00 
                  Button          =   -1  'True
                  Locked          =   -1  'True
                  ColumnWidth     =   1005.165
               EndProperty
               BeginProperty Column01 
                  Button          =   -1  'True
                  ColumnWidth     =   1200.189
               EndProperty
               BeginProperty Column02 
                  Locked          =   -1  'True
                  ColumnWidth     =   1920.189
               EndProperty
               BeginProperty Column03 
                  ColumnWidth     =   2115.213
               EndProperty
               BeginProperty Column04 
                  Alignment       =   1
                  Object.Visible         =   -1  'True
                  ColumnWidth     =   1440
               EndProperty
            EndProperty
         End
         Begin VB.ComboBox cboOthers 
            Height          =   315
            ItemData        =   "frmARCollection.frx":0004
            Left            =   -74970
            List            =   "frmARCollection.frx":000E
            Style           =   2  'Dropdown List
            TabIndex        =   14
            Top             =   810
            Visible         =   0   'False
            Width           =   1320
         End
         Begin MSDataGridLib.DataGrid dtgMap 
            Height          =   1785
            Left            =   -75000
            TabIndex        =   13
            Top             =   315
            Width           =   8790
            _ExtentX        =   15505
            _ExtentY        =   3149
            _Version        =   393216
            AllowUpdate     =   -1  'True
            AllowArrows     =   -1  'True
            BackColor       =   16777215
            HeadLines       =   1
            RowHeight       =   15
            TabAcrossSplits =   -1  'True
            TabAction       =   2
            FormatLocked    =   -1  'True
            AllowDelete     =   -1  'True
            BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ColumnCount     =   4
            BeginProperty Column00 
               DataField       =   "cBankID"
               Caption         =   "Bank"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column01 
               DataField       =   "cCheckNo"
               Caption         =   "Check No."
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column02 
               DataField       =   "cInvNo"
               Caption         =   "Invoice No."
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column03 
               DataField       =   "nAmount"
               Caption         =   "Amount"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            SplitCount      =   1
            BeginProperty Split0 
               BeginProperty Column00 
                  Locked          =   -1  'True
                  ColumnWidth     =   1214.929
               EndProperty
               BeginProperty Column01 
                  Locked          =   -1  'True
                  ColumnWidth     =   2849.953
               EndProperty
               BeginProperty Column02 
                  Locked          =   -1  'True
                  ColumnWidth     =   1814.74
               EndProperty
               BeginProperty Column03 
                  Alignment       =   1
                  Locked          =   -1  'True
                  ColumnWidth     =   1800
               EndProperty
            EndProperty
         End
         Begin ITGControls.ITGCommandButton cmdMap 
            Height          =   315
            Left            =   -68865
            TabIndex        =   12
            Top             =   2160
            Width           =   1275
            _ExtentX        =   2249
            _ExtentY        =   556
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Caption         =   "Check Mapping"
         End
         Begin ITGControls.ITGCommandButton cmdClearMap 
            Height          =   315
            Left            =   -67545
            TabIndex        =   11
            Top             =   2160
            Width           =   1275
            _ExtentX        =   2249
            _ExtentY        =   556
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Caption         =   "Clear"
         End
      End
      Begin ITGControls.ITGTextBox txtPayTotal 
         Height          =   285
         Left            =   120
         TabIndex        =   19
         Top             =   3570
         Width           =   2535
         _ExtentX        =   4260
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Applied Amt"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1160
         TextBoxWidth    =   1315
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtInvTotal 
         Height          =   285
         Left            =   120
         TabIndex        =   20
         Top             =   3210
         Width           =   2535
         _ExtentX        =   4260
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Invoice Amt"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1160
         TextBoxWidth    =   1315
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtToApply 
         Height          =   285
         Left            =   120
         TabIndex        =   21
         Top             =   4290
         Width           =   2535
         _ExtentX        =   4260
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "To Apply"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1160
         TextBoxWidth    =   1315
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtCash 
         Height          =   285
         Left            =   3540
         TabIndex        =   22
         Top             =   3570
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Cash"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtPDC 
         Height          =   285
         Left            =   3540
         TabIndex        =   23
         Top             =   3210
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Check"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtEWT 
         Height          =   285
         Left            =   3540
         TabIndex        =   24
         Top             =   3930
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "EWT"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtOthers 
         Height          =   285
         Left            =   120
         TabIndex        =   25
         Top             =   3930
         Width           =   2535
         _ExtentX        =   4260
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Other Amt"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1160
         TextBoxWidth    =   1315
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtEVAT 
         Height          =   285
         Left            =   3540
         TabIndex        =   26
         Top             =   4290
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "EVAT"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
   End
   Begin ITGControls.ITGTab SSTab2 
      Height          =   6810
      Left            =   0
      TabIndex        =   8
      Top             =   0
      Width           =   8805
      _ExtentX        =   15531
      _ExtentY        =   12012
      TabCount        =   2
      TabCaption(0)   =   "               Main               "
      TabContCtrlCnt(0)=   1
      Tab(0)ContCtrlCap(1)=   "ComunionFrames1"
      TabCaption(1)   =   "               List               "
      TabContCtrlCnt(1)=   1
      Tab(1)ContCtrlCap(1)=   "dtgList"
      TabTheme        =   2
      ActiveTabBackStartColor=   16250865
      ActiveTabBackEndColor=   16243138
      InActiveTabBackStartColor=   16243138
      InActiveTabBackEndColor=   16243138
      InActiveTabForeColor=   0
      BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OuterBorderColor=   4210752
      TopLeftInnerBorderColor=   4210752
      BottomRightInnerBorderColor=   4210752
      DisabledTabBackColor=   16243138
      DisabledTabForeColor=   -2147483630
      Begin MSDataGridLib.DataGrid dtgList 
         Height          =   1785
         Left            =   -75000
         TabIndex        =   6
         Top             =   315
         Width           =   8805
         _ExtentX        =   15531
         _ExtentY        =   3149
         _Version        =   393216
         AllowUpdate     =   0   'False
         AllowArrows     =   -1  'True
         Appearance      =   0
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   6
         BeginProperty Column00 
            DataField       =   "cTranNo"
            Caption         =   "Receipt No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "dDate"
            Caption         =   "Date"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cCode"
            Caption         =   "Client Code"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "nInvTotal"
            Caption         =   "Invoice Amount"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "nPayTotal"
            Caption         =   "Payment Amount"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "nOthersTotal"
            Caption         =   "Others Amount"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            AllowRowSizing  =   0   'False
            BeginProperty Column00 
               Locked          =   -1  'True
               ColumnWidth     =   1395.213
            EndProperty
            BeginProperty Column01 
               Locked          =   -1  'True
               ColumnWidth     =   1170.142
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               ColumnWidth     =   1200.189
            EndProperty
            BeginProperty Column03 
               Alignment       =   1
               Locked          =   -1  'True
            EndProperty
            BeginProperty Column04 
               Alignment       =   1
               Locked          =   -1  'True
            EndProperty
            BeginProperty Column05 
               Alignment       =   1
            EndProperty
         EndProperty
      End
      Begin ITGControls.ComunionFrames ComunionFrames1 
         Height          =   1785
         Left            =   0
         Top             =   315
         Width           =   8805
         _ExtentX        =   15531
         _ExtentY        =   3149
         FrameColor      =   4210752
         BackColor       =   16243138
         FillColor       =   16243138
         RoundedCorner   =   0   'False
         Caption         =   "Customer Information"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ThemeColor      =   5
         ColorFrom       =   16243138
         ColorTo         =   16250865
         Begin VB.CommandButton cmdPickClient 
            Height          =   300
            Left            =   2490
            Picture         =   "frmARCollection.frx":0021
            Style           =   1  'Graphical
            TabIndex        =   2
            Top             =   810
            Width           =   315
         End
         Begin VB.Timer Timer1 
            Interval        =   300
            Left            =   2505
            Top             =   375
         End
         Begin ITGControls.ITGDateBox dtbDate 
            Height          =   285
            Left            =   6855
            TabIndex        =   1
            Tag             =   "Receipt Date"
            Top             =   495
            Width           =   1320
            _ExtentX        =   2328
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   ""
            SendKeysTab     =   -1  'True
            Mandatory       =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtTranNo 
            Height          =   285
            Left            =   90
            TabIndex        =   0
            Top             =   495
            Width           =   2370
            _ExtentX        =   3969
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Receipt No."
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1160
            TextBoxWidth    =   1150
            Required        =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtName 
            Height          =   285
            Left            =   2805
            TabIndex        =   3
            Top             =   810
            Width           =   3750
            _ExtentX        =   6509
            _ExtentY        =   503
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   3690
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtCode 
            Height          =   285
            Left            =   105
            TabIndex        =   5
            Top             =   810
            Width           =   2355
            _ExtentX        =   3942
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Customer"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1160
            TextBoxWidth    =   1135
            Required        =   -1  'True
            LinkForeColor   =   16711680
         End
         Begin ITGControls.ITGTextBox txtRemarks 
            Height          =   285
            Left            =   105
            TabIndex        =   4
            Top             =   1125
            Width           =   6450
            _ExtentX        =   11165
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Remarks"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1160
            TextBoxWidth    =   5230
            LinkForeColor   =   0
         End
         Begin VB.Label Label1 
            BackStyle       =   0  'Transparent
            Caption         =   "Date"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Left            =   6120
            TabIndex        =   9
            Top             =   525
            Width           =   840
         End
      End
   End
End
Attribute VB_Name = "frmARCollection"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.08.11

Option Explicit

'Object variables




Private oPrint As New clsPrinting


'Recordset variables
Private WithEvents rsHeader As ADODB.Recordset
Attribute rsHeader.VB_VarHelpID = -1
Private rsInvoice As ADODB.Recordset
Private rsPayment As ADODB.Recordset
Private rsOthers As ADODB.Recordset
Private rsMapping As ADODB.Recordset

'ADO Connection variables

Private connHeader As ADODB.Connection
Private connInvoice As ADODB.Connection
Private connPayment As ADODB.Connection
Private connOthers As ADODB.Connection
Private connMapping As ADODB.Connection

'Form mode enumeration
Enum eCollectionMode
    Normal
    AddNewEdit
    Find
End Enum
Public Mode As eCollectionMode

'Other declaration
Public dtgName As String
Public sBit As String
Private vBM As Variant 'Recordset bookmark variable

Private lSystemGenerated As Boolean
Public strNo As String

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean

Private Sub cboOthers_Click()
    If dtgOthers.Col = 0 Then
        rsOthers!cType = cboOthers
    End If
End Sub

Private Sub cboOthers_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If dtgOthers.Col = 0 Then
            rsOthers!cType = cboOthers
            cboOthers.Visible = False
            dtgOthers.Col = 1
            dtgOthers.SetFocus
        End If
    ElseIf KeyCode = vbKeyEscape Then
        cboOthers.Visible = False
    End If
End Sub

Private Sub cboOthers_LostFocus()
    cboOthers.Visible = False
End Sub

Private Sub cboPR_C_Click()
    If dtgPayment.Col = 0 Then
        rsPayment!cType = cboPR_C
    End If
End Sub

Private Sub cboPR_C_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If dtgPayment.Col = 0 Then
            rsPayment!cType = cboPR_C
            cboPR_C.Visible = False
            dtgPayment.Col = 1
            dtgPayment.SetFocus
        End If
    ElseIf KeyCode = vbKeyEscape Then
        cboPR_C.Visible = False
    End If
End Sub

Private Sub cboPR_C_LostFocus()
    cboPR_C.Visible = False
End Sub

Private Sub cmdClearMap_Click()
    
    rsMapping.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
        
    If rsMapping.RecordCount <> 0 Then rsMapping.MoveFirst
    Do Until rsMapping.EOF
        rsMapping.Delete
        rsMapping.MoveNext
    Loop
    
    rsMapping.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    
End Sub

Private Sub cmdMap_Click()
    If Mode <> AddNewEdit Then Exit Sub
    If Not MandatoryOK Then Exit Sub
    Mapping
    LockMapGrid False
End Sub

Private Sub cmdPickClient_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtCode)
    frmITGPicker.zType = QCustomer
    frmITGPicker.Show vbModal
    txtCode = frmITGPicker.zCode
    txtName = frmITGPicker.zName
    If Trim(txtName) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub dtgInvoice_AfterColUpdate(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0
'            sSQL = "SELECT A.cInvNo FROM SALES A " & _
'                    "INNER JOIN V_SalesBalanceInquiry B ON A.cInvNo = B.cInvNo AND A.cCompanyID = B.cCompanyID " & _
'                    "WHERE A.cInvNo = '" & Trim(dtgInvoice.Columns(0).Value) & "' " & _
'                    "AND A.cCompanyID = '" & COID & "' AND A.cCode = '" & Trim(txtCode) & "' " & _
'                    "AND ((B.nSales - B.nPaid - B.nReturns - B.nCredit + B.nDebit) <> 0)"
            sSQL = "SELECT A.cInvNo " & _
                "FROM SALES A " & _
                "INNER JOIN V_SalesBalanceInquiry B ON A.cInvNo = B.cInvNo AND A.cCompanyID = B.cCompanyID " & _
                "WHERE A.cCompanyID = '" & COID & "' AND ((B.nSales - B.nPaid - B.nReturns - B.nCredit + B.nDebit) <> 0) " & _
                    "AND A.cCode = '" & Trim(txtCode) & "' AND A.cInvNo = '" & Trim(dtgInvoice.Columns(0).Value) & "' " & _
                "UNION ALL " & _
                "SELECT A.cInvNo " & _
                "FROM SALES A " & _
                "INNER JOIN V_SalesBalanceInquiry B ON A.cInvNo = B.cInvNo AND A.cCompanyID = B.cCompanyID " & _
                "LEFT OUTER JOIN CLIENT_CUSTOMER C ON A.cCompanyID = C.cCompanyID AND A.cCode = C.cCode " & _
                "WHERE A.cCompanyID = '" & COID & "' AND ((B.nSales - B.nPaid - B.nReturns - B.nCredit + B.nDebit) <> 0) " & _
                    "AND A.cCode <> '" & Trim(txtCode) & "' AND C.cGroupCode = '" & Trim(txtCode) & "' AND A.cInvNo = '" & Trim(dtgInvoice.Columns(0).Value) & "'"
            Set rs = New Recordset
            rs.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
            If rs.RecordCount <> 0 Then
                GetInvoiceDetails
                dtgInvoice.Col = 3
                If GetValueFrTable("lEWT", "CLIENT_CUSTOMER", "cCode = '" & txtCode.Text & "'") Then
                    dtgInvoice.Columns(3).Value = rsInvoice!nApplied * 0.99
                    dtgInvoice.Columns(4).Value = rsInvoice!nApplied * 0.01
                Else
                    dtgInvoice.Columns(3).Value = rsInvoice!nApplied
                End If
            End If
            Set rs = Nothing
        Case 3
            TotalAppliedAmount
            ToApplyAmount
        Case 4
            
            TotalAppliedAmount
            ToApplyAmount
        Case 5
            TotalAppliedAmount
            ToApplyAmount
    End Select
End Sub

Private Sub dtgInvoice_ButtonClick(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0
            RepName = Trim(txtCode)
            frmARCollectionList.mSIPick = ToCollection
            frmARCollectionList.Show vbModal
    End Select
End Sub

'Set the datagrid as active control
Private Sub dtgInvoice_Click()
    If Mode = AddNewEdit Then dtgName = dtgInvoice.Name
End Sub

Private Sub dtgInvoice_Error(ByVal DataError As Integer, Response As Integer)
    If Mode <> AddNewEdit Then
        Response = 0
        Exit Sub
    End If
    If DataError = 7007 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    ElseIf DataError = 13 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    End If
    Response = 0
End Sub

Private Sub dtgInvoice_GotFocus()
    dtgName = dtgInvoice.Name
End Sub

Private Sub dtgInvoice_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgInvoice_KeyPress(KeyAscii As Integer)
    
    If Mode <> AddNewEdit Then Exit Sub
    If rsInvoice.RecordCount = 0 Then Exit Sub
    
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    
    If KeyAscii = 13 Then
        Select Case dtgInvoice.Col
            Case 0
'                sSQL = "SELECT A.cInvNo FROM SALES A " & _
'                        "INNER JOIN V_SalesBalanceInquiry B ON A.cInvNo = B.cInvNo AND A.cCompanyID = B.cCompanyID " & _
'                        "WHERE A.cInvNo = '" & Trim(dtgInvoice.Columns(0).Value) & "' " & _
'                        "AND A.cCompanyID = '" & COID & "' AND A.cCode = '" & Trim(txtCode) & "' " & _
'                        "AND ((B.nSales - B.nPaid - B.nReturns - B.nCredit + B.nDebit) <> 0)"
                sSQL = "SELECT A.cInvNo " & _
                    "FROM SALES A " & _
                    "INNER JOIN V_SalesBalanceInquiry B ON A.cInvNo = B.cInvNo AND A.cCompanyID = B.cCompanyID " & _
                    "WHERE A.cCompanyID = '" & COID & "' AND ((B.nSales - B.nPaid - B.nReturns - B.nCredit + B.nDebit) <> 0) " & _
                        "AND A.cCode = '" & Trim(txtCode) & "' AND A.cInvNo = '" & Trim(dtgInvoice.Columns(0).Value) & "' " & _
                    "UNION ALL " & _
                    "SELECT A.cInvNo " & _
                    "FROM SALES A " & _
                    "INNER JOIN V_SalesBalanceInquiry B ON A.cInvNo = B.cInvNo AND A.cCompanyID = B.cCompanyID " & _
                    "LEFT OUTER JOIN CLIENT_CUSTOMER C ON A.cCompanyID = C.cCompanyID AND A.cCode = C.cCode " & _
                    "WHERE A.cCompanyID = '" & COID & "' AND ((B.nSales - B.nPaid - B.nReturns - B.nCredit + B.nDebit) <> 0) " & _
                        "AND A.cCode <> '" & Trim(txtCode) & "' AND C.cGroupCode = '" & Trim(txtCode) & "' AND A.cInvNo = '" & Trim(dtgInvoice.Columns(0).Value) & "'"
                Set rs = New Recordset
                rs.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
                If rs.RecordCount = 0 Then
                    dtgInvoice.Col = 0
                    dtgInvoice_ButtonClick 0
                Else
                    SendKeys "{Tab}"
                End If
                Set rs = Nothing
            Case 5
                TBNewLine
                dtgInvoice.LeftCol = 0
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii))) 'All Upper Case String
    End If

End Sub

'Right click menu popup
Private Sub dtgInvoice_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgInvoice.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub
'
'Private Sub dtgList_HeadClick(ByVal ColIndex As Integer)
'    SortGrid dtgList, ColIndex, rsHeader
'End Sub

Private Sub dtgList_HeadClick(ByVal ColIndex As Integer)
    SortGrid dtgList, ColIndex, rsHeader
End Sub

Private Sub dtgMap_AfterColUpdate(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0
            If IsNull(rsMapping!cCheckNo) Then Exit Sub
            If Trim(rsMapping!cCheckNo) = "" Then Exit Sub
            CheckMappingDetailOK
        Case 1
            CheckMappingDetailOK
        Case 2
            CheckMappingDetailInvOK
    End Select
End Sub

'Set the datagrid as active control
Private Sub dtgMap_Click()
    If Mode = AddNewEdit Then dtgName = dtgMap.Name
End Sub

Private Sub dtgMap_Error(ByVal DataError As Integer, Response As Integer)
    If Mode <> AddNewEdit Then
        Response = 0
        Exit Sub
    End If
    If DataError = 7007 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    ElseIf DataError = 13 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    End If
    Response = 0
End Sub

Private Sub dtgMap_GotFocus()
    dtgName = dtgMap.Name
End Sub

Private Sub dtgMap_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgMap_KeyPress(KeyAscii As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    
    If KeyAscii = 13 Then
        SendKeys "{Tab}"
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii))) 'All Upper Case String
    End If
End Sub

'Right click menu popup
Private Sub dtgMap_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgMap.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub

Private Sub dtgOthers_AfterColUpdate(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 1
            If GetValueFrTable("cAcctNo", "ACCOUNT", "cAcctNo = '" & Trim(dtgOthers.Columns(1).Text) & "'") <> "" Then
                dtgOthers.Columns(2).Value = GetValueFrTable("cTitle", "ACCOUNT", "cAcctNo = '" & Trim(dtgOthers.Columns(1).Text) & "'")
                dtgOthers.Col = 3
                dtgOthers.Columns(3).Value = rsOthers!cDesc
            End If
        Case 4
            TotalOthersAmount
            ToApplyAmount
    End Select
End Sub

Private Sub dtgOthers_ButtonClick(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0 'Detail type
            MoveCombo cboOthers, dtgOthers, dtgOthers.Columns(0)
            ComboLoadValue cboOthers, Trim(dtgOthers.Columns(0).Text)
            cboOthers.SetFocus
        Case 1 'Account Number
            If lPickListActive Then Exit Sub
            sFilterString = Trim(dtgOthers.Columns(1).Text)
            frmITGPicker.zType = QAccounts
            frmITGPicker.Show vbModal
            If Trim(frmITGPicker.zCode) = "" Then Exit Sub
            dtgOthers.Columns(1).Value = frmITGPicker.zCode & ""
            dtgOthers.Columns(2).Value = frmITGPicker.zName & ""
            dtgOthers.Col = 3
            dtgOthers.Columns(3).Value = rsOthers!cDesc
    End Select
End Sub

'Set the datagrid as active control
Private Sub dtgOthers_Click()
    If Mode = AddNewEdit Then dtgName = dtgOthers.Name
End Sub

Private Sub dtgOthers_Error(ByVal DataError As Integer, Response As Integer)
    If Mode <> AddNewEdit Then
        Response = 0
        Exit Sub
    End If
    If DataError = 7007 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    ElseIf DataError = 13 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    End If
    Response = 0
End Sub

Private Sub dtgOthers_GotFocus()
    dtgName = dtgOthers.Name
End Sub

Private Sub dtgOthers_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgOthers_KeyPress(KeyAscii As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If rsOthers.RecordCount = 0 Then Exit Sub
    
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    
    If KeyAscii = 13 Then
        Select Case dtgOthers.Col
            Case 0
                If Not cboOthers.Visible Then dtgOthers_ButtonClick 0
            Case 1
                If GetValueFrTable("cAcctNo", "ACCOUNT", "cAcctNo = '" & Trim(dtgOthers.Columns(1).Text) & "'") = "" Then
                    dtgOthers_ButtonClick (1)
                End If
            Case 4
                TBNewLine
                dtgOthers.LeftCol = 0
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii))) 'All Upper Case String
    End If
End Sub

'Right click menu popup
Private Sub dtgOthers_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgOthers.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub

Private Sub dtgPayment_AfterColUpdate(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 1
            If GetValueFrTable("cBankID", "BANK", "cBankID = '" & Trim(dtgPayment.Columns(1).Text) & "'") <> "" Then
                dtgPayment.Col = 2
                dtgPayment.Columns(2).Value = rsPayment!cCheckNo
            End If
        Case 2
            If Trim(rsPayment!cType) = "CSH" Then Exit Sub
            If Trim(rsPayment!cType) = "OFF" Then Exit Sub
            If Trim(dtgPayment.Columns(1).Text) = "" Then
                MsgBox "BANK is required."
                dtgPayment.Columns(2).Value = rsPayment!cBankID
                dtgPayment.Col = 1
                dtgPayment.Columns(1).Value = rsPayment!cBankID
                Exit Sub
            End If
            If CheckExisting(rsPayment!cCheckNo, rsPayment!cBankID, rsHeader!cTranNo, rsPayment, True) Then
                MsgBox "Check already exist."
                Exit Sub
            End If
        Case 4
            TotalPaymentAmount
            ToApplyAmount
    End Select
End Sub

Private Sub dtgPayment_ButtonClick(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0 'Payment type
            Call LoadComboValues(cboPR_C, "cValue", "PARAMETER_USER", "WHERE cCompanyID = '" & COID & "' AND cType = 'PAYTYPE'", "nOrder")
            Call MoveCombo(cboPR_C, dtgPayment, dtgPayment.Columns(0))
            ComboLoadValue cboPR_C, Trim(dtgPayment.Columns(0).Text)
        Case 1 'Bank ID
            If lPickListActive Then Exit Sub
            frmITGPickList.mType = Bank
            frmITGPickList.Show vbModal
            If Trim(frmITGPickList.mCode) = "" Then Exit Sub
            dtgPayment.Columns(1).Value = frmITGPickList.mCode & ""
            dtgPayment.Col = 2
            dtgPayment.Columns(2).Value = rsPayment!cCheckNo
    End Select
End Sub

'Set the datagrid as active control
Private Sub dtgPayment_Click()
    If Mode = AddNewEdit Then dtgName = dtgPayment.Name
End Sub

Private Sub dtgPayment_Error(ByVal DataError As Integer, Response As Integer)
    If Mode <> AddNewEdit Then
        Response = 0
        Exit Sub
    End If
    If DataError = 7007 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    ElseIf DataError = 13 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    End If
    Response = 0
End Sub

Private Sub dtgPayment_GotFocus()
    dtgName = dtgPayment.Name
End Sub

Private Sub dtgPayment_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgPayment_KeyPress(KeyAscii As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If rsPayment.RecordCount = 0 Then Exit Sub
    
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    
    If KeyAscii = 13 Then
        Select Case dtgPayment.Col
            Case 0
                If Not cboPR_C.Visible Then dtgPayment_ButtonClick 0
            Case 1
                If GetValueFrTable("cBankID", "BANK", "cBankID = '" & Trim(dtgPayment.Columns(1).Text) & "'") = "" Then
                    If Trim(dtgPayment.Columns(0).Text) = "CSH" Then
                        SendKeys "{Tab}"
                        SendKeys "{Tab}"
                        dtgPayment.Columns(3).Text = Format(Date, "MM/dd/yyyy")
                    Else
                        dtgPayment_ButtonClick (1) 'use button click
                    End If
                End If
            Case 4
                TBNewLine
                dtgPayment.LeftCol = 0
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii))) 'All Upper Case String
    End If
End Sub

'Right click menu popup
Private Sub dtgPayment_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgPayment.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Dim iKey As Integer
    iKey = ToolbarIndex(KeyCode, Shift)
    If iKey <> 0 Then
        If ITGLedgerMain.tbrMain.Buttons(iKey).Enabled = True Then
            ToolbarFunction iKey
        End If
    End If
End Sub

'Set Your Object
Private Sub Form_Load()
    Set FrmName = Me
    FormSetup
    
    AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'CC01'")
    
    Set rsHeader = New ADODB.Recordset
    Set rsInvoice = New ADODB.Recordset
    Set rsPayment = New ADODB.Recordset
    Set rsOthers = New ADODB.Recordset
    Set rsMapping = New ADODB.Recordset
    
    
    FormLocking True
    FormSearch True
    SearchObj True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True

    Mode = Find
    txtTranNo.Locked = False
    
    
End Sub

'Activate your Toolbar Mode
Private Sub Form_Activate()
    TBBitReload
End Sub

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    If Mode = AddNewEdit Then
        MsgBox "Unable to close. You are in Add/New/Edit mode." & vbCr & _
            " Must Save or Undo", vbCritical, Me.Caption
        Cancel = True
        Exit Sub
    End If
    
    CloseMenuTab ITGLedgerMain
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False
    
    
    
    
    
    Set oPrint = Nothing
    Set rsHeader = Nothing
    Set rsInvoice = Nothing
    Set rsPayment = Nothing
    Set rsOthers = Nothing
    Set rsMapping = Nothing
    Set connHeader = Nothing
    Set connInvoice = Nothing
    Set connPayment = Nothing
    Set connOthers = Nothing
    Set connMapping = Nothing
    
    Set frmARCollection = Nothing

    lCloseWindow = True
    
End Sub

'Add new record to the recordset
Public Sub TBNew()
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    txtTranNo.BackColor = &HE0FFFF
    Mode = AddNewEdit
    
    If rsHeader.State <> adStateOpen Then
        OpenNewConnection connMapping
        OpenNewConnection connOthers
        OpenNewConnection connPayment
        OpenNewConnection connInvoice
        OpenNewConnection connHeader
        OpenRecordsetWithCN rsMapping, "*", "PR_MAP", connMapping, "WHERE 1 = 0"
        OpenRecordsetWithCN rsOthers, "*", "PR_O", connOthers, "WHERE 1 = 0"
        OpenRecordsetWithCN rsPayment, "*", "PR_C", connPayment, "WHERE 1 = 0"
        OpenRecordsetWithCN rsInvoice, "*", "PR_T", connInvoice, "WHERE 1 = 0"
        OpenRecordsetWithCN rsHeader, "*", "PR", connHeader, "WHERE 1 = 0"
        SetDataSource
        SetDataField
    Else
        vBM = rsHeader.Bookmark
    End If
    
    rsHeader.AddNew
    rsHeader!cCompanyID = COID
    rsHeader!dDate = Date
    
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    SSTab1.ActiveTab = 0
    txtTranNo.SetFocus
    
    'System generated number
    lSystemGenerated = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'AUTO_NUMBER_OR' ")

    If lSystemGenerated Then rsHeader!cTranNo = GetAutoCtrlNo(rsHeader, "AUTO_NUMBER_OR", "PR", "cTranNo")

End Sub

'Undo all changes to the recordset
Public Sub TBUndoAll()
On Error GoTo ErrorHandler

    Mode = Normal
    
    If rsHeader.Status = adRecNew Then TBUndoCurrent
    
    rsHeader.CancelBatch adAffectAll
    rsInvoice.CancelBatch adAffectAll
    rsPayment.CancelBatch adAffectAll
    rsOthers.CancelBatch adAffectAll
    rsMapping.CancelBatch adAffectAll
    
    UnbindControls
    
    If rsHeader.RecordCount <> 0 Then rsHeader.Bookmark = vBM
    
    Set FrmName = Me
    FormLocking True
    
    If rsHeader.RecordCount <> 0 Then
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True, True
    Else
        RSZero
        Mode = Find
    End If
    
    LockMapGrid True
    
    sbRS.Panels(2) = ""
    
    SetDataSource
    SetDataField

ErrorHandler:
    
    cboOthers.Visible = False
    cboPR_C.Visible = False
    
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoAll
    End If

End Sub

'Undo changes on the current record
Public Sub TBUndoCurrent()
On Error GoTo ErrorHandler

    GetChild
    If rsHeader.Status = adRecNew Then
        rsInvoice.CancelBatch adAffectAll
        rsPayment.CancelBatch adAffectAll
        rsOthers.CancelBatch adAffectAll
        rsMapping.CancelBatch adAffectAll
        rsHeader.CancelUpdate
    Else
        rsHeader.CancelBatch adAffectCurrent
        rsInvoice.CancelBatch adAffectAll
        rsPayment.CancelBatch adAffectAll
        rsOthers.CancelBatch adAffectAll
        rsMapping.CancelBatch adAffectAll
    End If
   
    If rsHeader.RecordCount = 0 Then RSZero
    
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoCurrent
    End If

End Sub

'Save all changes
Public Sub TBSave()
Dim OKUpdate As Boolean
On Error GoTo ErrHandler

    'Audit Trail
    lBoolean = False
    If rsHeader.Status = adRecNew Then lBoolean = True
    
    If Not MandatoryOK Then Exit Sub
    If Not CheckMappingOK Then Exit Sub
    
    'System generated number
    If rsHeader.Status = adRecNew Then
            If lSystemGenerated Then
            If ChkCtrlNo(rsHeader, "AUTO_NUMBER_OR", "PR", "cTranNo", rsHeader!cTranNo) <> rsHeader!cTranNo Then
                GetChild
                
                rsHeader!cTranNo = strNo
                
                If rsInvoice.RecordCount <> 0 Then rsInvoice.MoveFirst
                Do Until rsInvoice.EOF
                    rsInvoice!cTranNo = strNo
                    rsInvoice.MoveNext
                Loop
                
                If rsPayment.RecordCount <> 0 Then rsPayment.MoveFirst
                Do Until rsPayment.EOF
                    rsPayment!cTranNo = strNo
                    rsPayment.MoveNext
                Loop
                
                If rsOthers.RecordCount <> 0 Then rsOthers.MoveFirst
                Do Until rsOthers.EOF
                    rsOthers!cTranNo = strNo
                    rsOthers.MoveNext
                Loop
                
                If rsMapping.RecordCount <> 0 Then rsMapping.MoveFirst
                Do Until rsMapping.EOF
                    rsMapping!cTranNo = strNo
                    rsMapping.MoveNext
                Loop
                
                GetChild
            End If
        End If
    End If
    
    OKUpdate = False
    cn.BeginTrans
    connHeader.BeginTrans
    connInvoice.BeginTrans
    connPayment.BeginTrans
    connOthers.BeginTrans
    connMapping.BeginTrans
    
    rsHeader.UpdateBatch adAffectAll
    rsInvoice.UpdateBatch adAffectAll
    rsPayment.UpdateBatch adAffectAll
    rsOthers.UpdateBatch adAffectAll
    rsMapping.UpdateBatch adAffectAll
    
    cn.CommitTrans
    connHeader.CommitTrans
    connInvoice.CommitTrans
    connPayment.CommitTrans
    connOthers.CommitTrans
    connMapping.CommitTrans
    OKUpdate = True
    
    Set FrmName = Me
    FormLocking True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True
    Mode = Normal
    AddToChecksTable
    AddToEWTTable
    AddToEVATTable
    AutoCM
    
    'Audit trail
    UpdateLogFile "Collection", Trim(txtTranNo), IIf(lBoolean, "Inserted", "Updated")
    'Update GL Activity
    UpdateGLA "Update", "OR", Trim(txtTranNo)
    
    LockMapGrid True
    
    'update system generated number
    If lBoolean Then
        If lSystemGenerated And strNo = rsHeader!cTranNo Then UpdateControlNo strNo, rsHeader!cTranNo, "AUTO_NUMBER_OR"
    End If
        
    MsgBox "Record/s successfully saved.", vbInformation, "ComUnion"
        
    sbRS.Panels(2) = ""

ErrHandler:

    cboOthers.Visible = False
    cboPR_C.Visible = False

    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        OKUpdate = True
        cn.RollbackTrans
        connHeader.RollbackTrans
        connInvoice.RollbackTrans
        connPayment.RollbackTrans
        connOthers.RollbackTrans
        connMapping.RollbackTrans
        MsgBox "Record cannot be updated. Some values may have been changed by other user/s since last read." & vbCr & _
                "Records will be automatically refreshed. All changes made to the record will be gone upon refresh.", vbInformation, "ComUnion"
        vBookMark = rsHeader.Bookmark
        UnbindControls
        rsHeader.Requery
        rsInvoice.Requery
        rsPayment.Requery
        rsOthers.Requery
        rsMapping.Requery
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True
        Mode = Normal
        If rsHeader.RecordCount <> 0 Then
            Set FrmName = Me
            FormLocking True
            SetDataField
            SetDataSource
            rsHeader.Bookmark = vBookMark
        Else
            RSZero
        End If
    End If
    If Not OKUpdate Then
        MsgBox "Transaction update failed.", vbInformation, "ComUnion"
        cn.RollbackTrans
        connHeader.RollbackTrans
        connInvoice.RollbackTrans
        connPayment.RollbackTrans
        connOthers.RollbackTrans
        connMapping.RollbackTrans
        ErrorLog err.Number, err.Description, Me.Name 'Error log
    End If
    
End Sub

'Sets the form & recorset to add/edit mode
Public Sub TBEdit()
    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Edit is not allowed.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    Mode = AddNewEdit
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    txtTranNo.Locked = True
    SSTab1.ActiveTab = 0
    dtbDate.SetFocus
    vBM = rsHeader.Bookmark
End Sub

'Delete record
Public Sub TBDelete()
On Error GoTo ErrorHandler
    
    sID = Trim(txtTranNo)
    
    If rsHeader.RecordCount = 0 Then Exit Sub
    
    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Deletion is not allowed.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub
    
    cn.Execute "DELETE CHECKS WHERE cTranNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "' AND cTransType = 'COL'"
    cn.Execute "DELETE EWT WHERE cORNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'"
    cn.Execute "DELETE EVAT WHERE cORNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'"
    cn.Execute "DELETE AR WHERE cTranNo = 'E-" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'"
    cn.Execute "DELETE AR_T WHERE cTranNo = 'E-" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'"
    
    'Update GL Activity
    UpdateGLA "Delete", "OR", Trim(txtTranNo)
    
    GetChild
    If rsInvoice.RecordCount <> 0 Then
        rsInvoice.MoveFirst
        Do Until rsInvoice.RecordCount = 0
            rsInvoice.Delete adAffectCurrent
            If rsInvoice.RecordCount <> 0 Then rsInvoice.MoveFirst
        Loop
    End If
    If rsPayment.RecordCount <> 0 Then
        rsPayment.MoveFirst
        Do Until rsPayment.RecordCount = 0
            rsPayment.Delete adAffectCurrent
            If rsPayment.RecordCount <> 0 Then rsPayment.MoveFirst
        Loop
    End If
    If rsOthers.RecordCount <> 0 Then
        rsOthers.MoveFirst
        Do Until rsOthers.RecordCount = 0
            rsOthers.Delete adAffectCurrent
            If rsOthers.RecordCount <> 0 Then rsOthers.MoveFirst
        Loop
    End If
    If rsMapping.RecordCount <> 0 Then
        rsMapping.MoveFirst
        Do Until rsMapping.RecordCount = 0
            rsMapping.Delete adAffectCurrent
            If rsMapping.RecordCount <> 0 Then rsMapping.MoveFirst
        Loop
    End If
    
    'Audit trail
    UpdateLogFile "Collection", Trim(txtTranNo), "Deleted"

    rsHeader.Delete adAffectCurrent
    rsInvoice.UpdateBatch adAffectAll
    rsPayment.UpdateBatch adAffectAll
    rsOthers.UpdateBatch adAffectAll
    rsMapping.UpdateBatch adAffectAll
    rsHeader.UpdateBatch adAffectAll
        
    TBPrevRec

    Mode = Normal
    
    If rsHeader.RecordCount = 0 Then
        RSZero
    End If
    
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        cn.Execute "DELETE PR_MAP WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE PR_O WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE PR_C WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE PR_T WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE PR WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        Resume Next
    End If

End Sub

'Search using the frmITGSearch
Public Sub TBFind()
    Mode = Normal
    txtTranNo.Locked = True
    frmITGSearch.Show
End Sub

'Search using the recordset primary key
Public Sub TBFindPrimary()
Dim sTemp As String
If Mode = Find Then
    FormWaitShow App.Path & "\Transmit.avi", "Loading data . . ."
        
    OpenNewConnection connMapping
    OpenNewConnection connOthers
    OpenNewConnection connPayment
    OpenNewConnection connInvoice
    OpenNewConnection connHeader

    Set rsHeader = Nothing
    Set rsInvoice = Nothing
    Set rsPayment = Nothing
    Set rsOthers = Nothing
    Set rsMapping = Nothing
    Set rsHeader = New ADODB.Recordset
    Set rsInvoice = New ADODB.Recordset
    Set rsPayment = New ADODB.Recordset
    Set rsOthers = New ADODB.Recordset
    Set rsMapping = New ADODB.Recordset
            
    sTemp = Trim$(GetSearchString)
    If sTemp = "ERROR" Then
        MsgBox "Only Allows A - Z, 0 - 9, '.', ',' and %(wildcard)", vbExclamation, ""
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
        txtTranNo.Locked = False
        txtTranNo.SetFocus
        Exit Sub
    End If
            
    OpenRecordsetWithCN rsHeader, "*", "PR", connHeader, IIf(sTemp = "", "", " WHERE " & sTemp)
    'OpenRecordsetWithCN rsMapping, "*", "PR_MAP", connMapping
    'OpenRecordsetWithCN rsOthers, "*", "PR_O", connOthers
    'OpenRecordsetWithCN rsPayment, "*", "PR_C", connPayment
    'OpenRecordsetWithCN rsInvoice, "*", "PR_T", connInvoice
             
    OpenRecordsetWithCN rsMapping, "*", "PR_MAP", connMapping, IIf(sTemp = "", "", " WHERE cTranNo IN (SELECT cTranNo FROM PR WHERE " & sTemp & ")")
    OpenRecordsetWithCN rsOthers, "*", "PR_O", connOthers, IIf(sTemp = "", "", " WHERE cTranNo IN (SELECT cTranNo FROM PR WHERE " & sTemp & ")")
    OpenRecordsetWithCN rsPayment, "*", "PR_C", connPayment, IIf(sTemp = "", "", " WHERE cTranNo IN (SELECT cTranNo FROM PR WHERE " & sTemp & ")")
    OpenRecordsetWithCN rsInvoice, "*", "PR_T", connInvoice, IIf(sTemp = "", "", " WHERE cTranNo IN (SELECT cTranNo FROM PR WHERE " & sTemp & ")")
    
    Set FrmName = Me
    FormLocking True
            
      If rsHeader.RecordCount = 0 Then
        FormWaitHide
        MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
        RSZero
        FormSearch True
        SearchObj True
        Mode = Find
        Exit Sub
    End If
    SetDataSource
    SetDataField
    txtTranNo.BackColor = &HE0FFFF
    Mode = Normal
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True, True

    FormWaitHide
Else
    RSZero
    FormSearch True
    SearchObj True
    Mode = Find
    
End If

End Sub

Public Sub TBAccountAffected()
    RepName = "OR"
    frmAccountAffected.mModuleType = KPR
    frmAccountAffected.mRefPK = txtTranNo.Text
    frmAccountAffected.Show vbModal
End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
    dtgName = dtgInvoice.Name
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

'Move first
Public Sub TBFirstRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveFirst rsHeader
    
End Sub

'Move previous
Public Sub TBPrevRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MovePrevious rsHeader
    
End Sub

'Move next
Public Sub TBNextRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveNext rsHeader
    
End Sub

'Move last
Public Sub TBLastRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveLast rsHeader
    
End Sub

'Add new line to the detail recordset
Public Sub TBNewLine()
    
    If rsHeader!cTranNo = "" Then Exit Sub
    If Trim(txtCode) = "" Then
        MsgBox "Client code required.", vbInformation, "ComUnion"
        txtCode.SetFocus
        Exit Sub
    End If

    If dtgName = "dtgInvoice" Then
        rsInvoice.AddNew
        rsInvoice!cCompanyID = COID
        rsInvoice!cTranNo = Trim(txtTranNo)
        rsInvoice!dInvDate = rsInvoice!dInvDate
        dtgInvoice.Col = 0
        GetChild
        If rsInvoice.RecordCount <> 0 Then rsInvoice.MoveLast
        dtgInvoice.SetFocus
    ElseIf dtgName = "dtgPayment" Then
        rsPayment.AddNew
        rsPayment!cCompanyID = COID
        rsPayment!cTranNo = Trim(txtTranNo)
        dtgPayment.Col = 0
        GetChild
        If rsPayment.RecordCount <> 0 Then rsPayment.MoveLast
        dtgPayment.SetFocus
    ElseIf dtgName = "dtgOthers" Then
        rsOthers.AddNew
        rsOthers!cCompanyID = COID
        rsOthers!cTranNo = Trim(txtTranNo)
        dtgOthers.Col = 0
        GetChild
        If rsOthers.RecordCount <> 0 Then rsOthers.MoveLast
        dtgOthers.SetFocus
    ElseIf dtgName = "dtgMap" Then
        rsMapping.AddNew
        rsMapping!cCompanyID = COID
        rsMapping!cTranNo = Trim(txtTranNo)
        dtgMap.Col = 0
        GetChild
        If rsMapping.RecordCount <> 0 Then rsMapping.MoveLast
        dtgMap.SetFocus
    End If

End Sub

'Delete line in the detail recordset
Public Sub TBDeleteLine()
On Error GoTo ErrorHandler

    If dtgName = "dtgInvoice" Then
        If rsInvoice.RecordCount = 0 Then Exit Sub
        vBookMark = dtgInvoice.Bookmark
        GetChild
        dtgInvoice.Bookmark = vBookMark
        rsInvoice.Delete adAffectCurrent
    ElseIf dtgName = "dtgPayment" Then
        If rsPayment.RecordCount = 0 Then Exit Sub
        vBookMark = dtgPayment.Bookmark
        GetChild
        dtgPayment.Bookmark = vBookMark
        rsPayment.Delete adAffectCurrent
    ElseIf dtgName = "dtgOthers" Then
        If rsOthers.RecordCount = 0 Then Exit Sub
        vBookMark = dtgOthers.Bookmark
        GetChild
        dtgOthers.Bookmark = vBookMark
        rsOthers.Delete adAffectCurrent
    ElseIf dtgName = "dtgMap" Then
        If rsMapping.RecordCount = 0 Then Exit Sub
        vBookMark = dtgMap.Bookmark
        GetChild
        dtgMap.Bookmark = vBookMark
        rsMapping.Delete adAffectCurrent
    End If
    
    GetChild
    
    TotalAppliedAmount
    TotalPaymentAmount
    TotalOthersAmount
    ToApplyAmount

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo all
Public Sub TBUndoLineAll()
On Error GoTo ErrorHandler
    
    MsgBox "Unavailable on " & Me.Name

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If
End Sub

'Undo current line
Public Sub TBUndoLineCurrent()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Post current record
Public Sub TBPostRecord()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Cancel current record
Public Sub TBCancelRecord()
On Error GoTo ErrorHandler
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to cancel this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub

    cn.Execute "DELETE CHECKS WHERE cTranNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "' AND cTransType = 'COL'"
    cn.Execute "DELETE EWT WHERE cORNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'"
    cn.Execute "DELETE EVAT WHERE cORNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'"
    cn.Execute "DELETE AR WHERE cTranNo = 'E-" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'"
    cn.Execute "DELETE AR_T WHERE cTranNo = 'E-" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'"
    
    'Audit trail
    UpdateLogFile "Collection", Trim(txtTranNo), "Cancelled"

    cn.Execute ("UPDATE PR SET lCancelled = 1 WHERE cTranNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'")
    
    sbRS.Panels(5) = "CANCELLED"
    Mode = Normal
    
    rsHeader!lCancelled = True
    rsHeader.UpdateBatch adAffectAll

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Print
Public Sub TBPrintRecord()
    cModule = "Official_Receipt"
    oPrint.PrintReceipt Trim(txtTranNo)
End Sub

'Sets the data source of the controls
Sub SetDataSource()
    Set FrmName = Me
    BindControls rsHeader
    Set dtgInvoice.DataSource = rsInvoice
    Set dtgPayment.DataSource = rsPayment
    Set dtgOthers.DataSource = rsOthers
    Set dtgMap.DataSource = rsMapping
    Set dtgList.DataSource = rsHeader
    
End Sub
    
'Sets the data field for every bounded controls
Sub SetDataField()
    With rsHeader
        txtTranNo.DataField = !cTranNo
        dtbDate.DataField = !dDate
        txtCode.DataField = !cCode
        txtRemarks.DataField = !cRemarks
        txtInvTotal.DataField = !nInvTotal
        txtPayTotal.DataField = !nPayTotal
        txtOthers.DataField = !nOthersTotal
        txtPDC.DataField = !nPDC
        txtCash.DataField = !nCash
        txtEWT.DataField = !nEWT
        txtEVAT.DataField = !nEVAT
    End With
End Sub

Private Sub rsHeader_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error GoTo ErrorHandler
    
    If Not (rsHeader.EOF) Or Not (rsHeader.BOF) Then
        sbRS.Panels(1) = "Record: " & IIf((rsHeader.AbsolutePosition = -2), "0", rsHeader.AbsolutePosition) & "/" & rsHeader.RecordCount
        
        If rsHeader.Status <> adRecNew Then
            txtTranNo.Locked = True
        Else
            txtTranNo.Locked = False
        End If
        
        If Mode = AddNewEdit Then
            Select Case rsHeader.Status
                Case adRecNew
                    sbRS.Panels(2) = "New"
                Case adRecModified
                    sbRS.Panels(2) = "Modified"
                Case Else
                    sbRS.Panels(2) = ""
            End Select
        Else
            sbRS.Panels(2) = ""
        End If
        
        GetChild
        
        If rsHeader!lCancelled = True Then
            sbRS.Panels(5) = "CANCELLED"
        Else
            sbRS.Panels(5) = ""
        End If
    Else
        sbRS.Panels(1) = "Record: 0/0"
        sbRS.Panels(2) = ""
        txtTranNo.Locked = False
    End If

    If Mode = AddNewEdit Then
        dtgInvoice.Refresh
        dtgPayment.Refresh
        dtgOthers.Refresh
        dtgMap.Refresh
    End If
    
ErrorHandler:
    'Err.Number -2147217885
    'Description - Row handle referred to a deleted row or a row marked for deletion.
    If err.Number = -2147217885 Then
        Resume Next
    End If
    
End Sub

Private Sub Timer1_Timer()
    If Mode = AddNewEdit Then
        SSTab2.TabEnabled(1) = False
    Else
        SSTab2.TabEnabled(1) = True
    End If
End Sub

Private Sub txtCode_Change()
    txtName = ""
    txtName = GetValueFrTable("cName", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
End Sub

Private Sub txtCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtName) = "" And Trim(txtCode) <> "" Then cmdPickClient_Click
End Sub

Private Sub txtRemarks_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If rsInvoice.RecordCount = 0 Then
        dtgName = dtgInvoice.Name
        SSTab1.ActiveTab = 0
        TBNewLine
    End If
End Sub

Private Sub txtTranNo_LostFocus()
    'Does Code Already exists
    If Mode = AddNewEdit Then
        If Trim(txtTranNo) = "" Then
            MsgBox "Empty primary input.", vbInformation, "ComUnion"
            If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
            txtTranNo.SetFocus
        Else
            If rsHeader.Status <> adRecNew Then Exit Sub
            txtTranNo = Trim(txtTranNo)
            If IDExisting(rsHeader, "cTranNo", "PR", Trim(rsHeader!cTranNo)) Then
                MsgBox "Receipt No. already exists.", vbInformation, "ComUnion"
                If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
                txtTranNo.SetFocus
                Exit Sub
            End If
        End If
    End If
End Sub

'Check if all mandatory fields are complete
Function MandatoryOK() As Boolean
    
    MandatoryOK = True
    
    If Trim(txtTranNo) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Receipt Number' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtTranNo.SetFocus
        Exit Function
    End If
    
    TotalAppliedAmount
    TotalPaymentAmount
    TotalOthersAmount
    ToApplyAmount
    
    If CDbl(txtToApply) <> 0 Then
        MsgBox "Unbalanced transaction!", vbCritical, "ComUnion"
        MandatoryOK = False
        Exit Function
    End If
    
    If rsHeader.Status = adRecNew And lSystemGenerated = False Then
        If IDExisting(rsHeader, "cTranNo", "PR", Trim(rsHeader!cTranNo)) Then
            MandatoryOK = False
            MsgBox "Receipt No. already exists.", vbInformation, "ComUnion"
            txtTranNo.SetFocus
            Exit Function
        End If
    End If
    
    'Required fields
    If Trim(dtbDate.Text) = "__/__/____" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Date' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        dtbDate.SetFocus
        Exit Function
    ElseIf Trim(txtCode) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Customer' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtCode.SetFocus
        Exit Function
    End If
    
    GetChild
    
    If rsInvoice.RecordCount <> 0 Then rsInvoice.MoveFirst
    Do Until rsInvoice.EOF
        If rsInvoice.Status = (adRecNew) Or rsInvoice.Status = (adRecModified) Then
            If IsNull(rsInvoice!cInvNo) Then
                rsInvoice.Delete
            ElseIf Trim(rsInvoice!cInvNo) = "" Then
                rsInvoice.Delete
            Else
                rsInvoice.MoveNext
            End If
        Else
            rsInvoice.MoveNext
        End If
    Loop
    
    If rsPayment.RecordCount <> 0 Then rsPayment.MoveFirst
    Do Until rsPayment.EOF
        If rsPayment.Status = (adRecNew) Or rsPayment.Status = (adRecModified) Then
            If IsNull(rsPayment!cType) Then
                rsPayment.Delete
            ElseIf Trim(rsPayment!cType) = "" Then
                rsPayment.Delete
            Else
                rsPayment.MoveNext
            End If
        Else
            rsPayment.MoveNext
        End If
    Loop
    
    If rsOthers.RecordCount <> 0 Then rsOthers.MoveFirst
    Do Until rsOthers.EOF
        If rsOthers.Status = (adRecNew) Or rsOthers.Status = (adRecModified) Then
            If IsNull(rsOthers!cAcctNo) Then
                rsOthers.Delete
            ElseIf Trim(rsOthers!cAcctNo) = "" Then
                rsOthers.Delete
            Else
                rsOthers.MoveNext
            End If
        Else
            rsOthers.MoveNext
        End If
    Loop
    
    If rsMapping.RecordCount <> 0 Then rsMapping.MoveFirst
    Do Until rsMapping.EOF
        If rsMapping.Status = (adRecNew) Or rsMapping.Status = (adRecModified) Then
            If IsNull(rsMapping!cInvNo) Then
                rsMapping.Delete
            ElseIf Trim(rsMapping!cInvNo) = "" Then
                rsMapping.Delete
            Else
                rsMapping.MoveNext
            End If
        Else
            rsMapping.MoveNext
        End If
    Loop
    
    GetChild

End Function

'Filter detail recordset to header's primary
Private Sub GetChild()
    rsInvoice.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    rsPayment.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    rsOthers.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    rsMapping.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
End Sub

'Sets the form if record number is zero
Private Sub RSZero()
    sbRS.Panels(1) = "Record: 0/0"
    sbRS.Panels(2) = ""
    sbRS.Panels(4) = ""
    sbRS.Panels(5) = ""
    
    Set dtgInvoice.DataSource = Nothing
    Set dtgPayment.DataSource = Nothing
    Set dtgOthers.DataSource = Nothing
    Set dtgMap.DataSource = Nothing
    dtgInvoice.Refresh
    dtgPayment.Refresh
    dtgOthers.Refresh
    dtgMap.Refresh
    
    Set FrmName = Me
    UnbindControls
    TextClearing
    FormLocking True
    
    If rsHeader.State = adStateOpen Then rsHeader.Close
    If rsInvoice.State = adStateOpen Then rsInvoice.Close
    If rsPayment.State = adStateOpen Then rsPayment.Close
    If rsOthers.State = adStateOpen Then rsOthers.Close
    If rsMapping.State = adStateOpen Then rsMapping.Close
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    
    txtTranNo.Locked = False
    txtTranNo.SetFocus
    
    Mode = Find
End Sub

Sub SearchObj(lEnable As Boolean)
    dtbDate.Enabled = lEnable
    cmdPickClient.Enabled = lEnable
End Sub

'Add invoice details from collection invoice list
Public Sub AddDetailsFromList(InvNo As String, InvDate As String, InvBalance As Double)
    
    With rsInvoice
        !cInvNo = Trim(InvNo)
        !dInvDate = Trim(InvDate)
        !nInvBalance = InvBalance
        !nApplied = InvBalance
        dtgInvoice.Col = 3
        If GetValueFrTable("lEWT", "CLIENT_CUSTOMER", "cCode = '" & txtCode.Text & "'") Then
            dtgInvoice.Columns(3).Value = InvBalance * 0.99
            dtgInvoice.Columns(4).Value = InvBalance * 0.01
        Else
            dtgInvoice.Columns(3).Value = InvBalance
        End If
        
    End With
    
    TotalAppliedAmount
    ToApplyAmount

End Sub

'Get invoice details
Sub GetInvoiceDetails()
    
    Set rs = New Recordset
    
    sSQL = "SELECT A.cInvNo, A.dDate, (B.nSales - B.nPaid - B.nReturns - B.nCredit + B.nDebit) AS nBalance FROM SALES A " & _
            "INNER JOIN V_SalesBalanceInquiry B ON A.cInvNo = B.cInvNo AND A.cCompanyID = B.cCompanyID " & _
            "WHERE A.cInvNo = '" & Trim(dtgInvoice.Columns(0).Text) & "' AND A.cCompanyID = '" & COID & "' "
    rs.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
    
    With rs
        rsInvoice!dInvDate = Format(!dDate, "MM/dd/yyyy")
        rsInvoice!nInvBalance = !nBalance
        If GetValueFrTable("lEWT", "CLIENT_CUSTOMER", "cCode = '" & txtCode.Text & "'") Then
            rsInvoice!nApplied = !nBalance * 0.99
            rsInvoice!nEWT = !nBalance * 0.01
        Else
            rsInvoice!nApplied = !nBalance
        End If
        
    End With
    
    Set rs = Nothing
    
    TotalAppliedAmount
    ToApplyAmount
    
End Sub

Private Function GetSearchString() As String
On Error GoTo ErrorHandler
Dim sWhere As String

    GetSearchString = True

    If Trim$(txtTranNo.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cTranNo LIKE '" & Trim$(txtTranNo.Text) & "%'"
    End If

    If Trim$(dtbDate.Text) <> "__/__/____" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " dDate = '" & Trim$(dtbDate.Text) & "'"
    End If
    
    If Trim$(txtCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cCode LIKE '" & Trim$(txtCode.Text) & "%'"
    End If
    
    GetSearchString = Trim$(sWhere)

    Exit Function
ErrorHandler:
    GetSearchString = "ERROR"
End Function

'Compute amount (applied to invoice, EWT, Discount)
Sub TotalAppliedAmount()
Dim n, nEWT, nDiscount, nEVAT As Double
    
On Error Resume Next
    
    If Mode <> AddNewEdit Then Exit Sub
    
    n = 0
    nEWT = 0
    nDiscount = 0
    nEVAT = 0
    
    Set rs = New Recordset
    Set rs = rsInvoice.Clone
    rs.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"

    rs.MoveFirst
    Do Until rs.EOF
        nEWT = nEWT + IIf(IsNull(rs!nEWT), 0, rs!nEWT)
        nEVAT = nEVAT + IIf(IsNull(rs!nEVAT), 0, rs!nEVAT)
        nDiscount = nDiscount + IIf(IsNull(rs!nDiscount), 0, rs!nDiscount)
        n = n + IIf(IsNull(rs!nApplied), 0, rs!nApplied)
        rs.MoveNext
    Loop
    Set rs = Nothing
    
    rsHeader!nInvTotal = n
    rsHeader!nEWT = nEWT
    rsHeader!nEVAT = nEVAT
    rsHeader!nDiscount = nDiscount

End Sub

'Compute amount (payment, pdc, cash)
Sub TotalPaymentAmount()
Dim n, nPDC, nCash As Double
    
On Error Resume Next
    
    If Mode <> AddNewEdit Then Exit Sub
    
    n = 0
    nPDC = 0
    nCash = 0
    
    Set rs = New Recordset
    Set rs = rsPayment.Clone
    rs.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"

    rs.MoveFirst
    Do Until rs.EOF
        If UCase(Trim(rs!cType)) = "CHK" Then
            nPDC = nPDC + IIf(IsNull(rs!nAmount), 0, rs!nAmount)
        Else
            nCash = nCash + IIf(IsNull(rs!nAmount), 0, rs!nAmount)
        End If
        
        n = n + IIf(IsNull(rs!nAmount), 0, rs!nAmount)
        rs.MoveNext
    Loop
    Set rs = Nothing
    
    rsHeader!nPayTotal = n
    rsHeader!nPDC = nPDC
    rsHeader!nCash = nCash
    
End Sub

'Compute amount (others)
Sub TotalOthersAmount()
Dim n As Double
    
On Error Resume Next
    
    If Mode <> AddNewEdit Then Exit Sub
    
    n = 0
    Set rs = New Recordset
    Set rs = rsOthers.Clone
    rs.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"

    rs.MoveFirst
    Do Until rs.EOF
        If UCase(Trim(rs!cType)) = "DEBIT" Then
            n = n - IIf(IsNull(rs!nAmount), 0, rs!nAmount)
        ElseIf UCase(Trim(rs!cType)) = "CREDIT" Then
            n = n + IIf(IsNull(rs!nAmount), 0, rs!nAmount)
        End If
        rs.MoveNext
    Loop
    Set rs = Nothing
    
    rsHeader!nOthersTotal = n
    
End Sub

'Compute amount to apply
Sub ToApplyAmount()
Dim n1, n2, n3, n4, n5 As Double
    n1 = IIf(IsNull(rsHeader!nInvTotal), 0, rsHeader!nInvTotal)
    n2 = IIf(IsNull(rsHeader!nPayTotal), 0, rsHeader!nPayTotal)
    n3 = IIf(IsNull(rsHeader!nOthersTotal), 0, rsHeader!nOthersTotal)
    txtToApply = n1 - n2 + n3
End Sub

'Match checks to invoice
Sub Mapping()
Dim rsDummy As Recordset
Dim rsInvoiceC As New Recordset
Dim rsPaymentC As New Recordset
Dim dblInvAmnt As Double
Dim dblChkAmnt As Double

Dim cmdMatch As Command
Dim strInv As String

    Set rsDummy = New Recordset

    With rsDummy.Fields
        .Append "cInvNo", adBSTR, , adFldIsNullable
        .Append "nAmtApplied", adDouble, , adFldIsNullable
        .Append "cBankID", adBSTR, , adFldIsNullable
        .Append "cCheckNo", adBSTR, , adFldIsNullable
        .Append "cTranNo", adBSTR, , adFldIsNullable
    End With
   
    rsDummy.Open
    
    
    Set rsInvoiceC = rsInvoice.Clone
    Set rsPaymentC = rsPayment.Clone
    
    rsInvoiceC.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    rsPaymentC.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    'GetChild
    
    rsInvoiceC.Sort = "nApplied ASC"
    rsPaymentC.Sort = "nAmount ASC"

    rsInvoiceC.MoveFirst
    rsPaymentC.MoveFirst

    dblInvAmnt = rsInvoiceC!nApplied
    
    Do While Not rsPaymentC.EOF
        dblChkAmnt = rsPaymentC!nAmount
        
        Do While Not rsInvoiceC.EOF
            If dblChkAmnt >= dblInvAmnt Then
                rsDummy.AddNew
                rsDummy!cInvNo = Trim(rsInvoiceC!cInvNo)
                rsDummy!cTranNo = rsInvoiceC!cTranNo
                rsDummy!nAmtApplied = dblInvAmnt
                rsDummy!cBankID = rsPaymentC!cBankID
                rsDummy!cCheckNo = IIf(IsNull(rsPaymentC!cCheckNo), "CASH", Trim(rsPaymentC!cCheckNo))
                dblChkAmnt = dblChkAmnt - dblInvAmnt
                rsInvoiceC.MoveNext 'ins
                If Not rsInvoiceC.EOF Then
                    dblInvAmnt = rsInvoiceC!nApplied
                End If
            
            Else
            
                rsDummy.AddNew
                rsDummy!cInvNo = IIf(IsNull(Trim(rsInvoiceC!cInvNo)), "", Trim(rsInvoiceC!cInvNo))
                rsDummy!cTranNo = rsInvoiceC!cTranNo
                rsDummy!nAmtApplied = dblChkAmnt
                rsDummy!cBankID = rsPaymentC!cBankID
                rsDummy!cCheckNo = IIf(IsNull(rsPaymentC!cCheckNo), "CASH", Trim(rsPaymentC!cCheckNo))
                dblInvAmnt = dblInvAmnt - dblChkAmnt
                Exit Do
            End If
        Loop
        rsPaymentC.MoveNext
    Loop

    If Not rsDummy.RecordCount = 0 Then
        rsDummy.Sort = "nAmtApplied ASC"
        rsDummy.MoveFirst
        rsInvoiceC.MoveFirst
    End If
    
    Do While Not rsDummy.EOF
        If rsDummy!nAmtApplied > 0 Then
            rsMapping.AddNew
            rsMapping!cCompanyID = COID
            rsMapping!cInvNo = IIf(IsNull(rsDummy!cInvNo), "", Trim(rsDummy!cInvNo))
            rsMapping!nAmount = IIf(IsNull(rsDummy!nAmtApplied), "", rsDummy!nAmtApplied)
            rsMapping!cTranNo = IIf(IsNull(rsDummy!cTranNo), "", rsDummy!cTranNo)
            rsMapping!cBankID = IIf(IsNull(rsDummy!cBankID), "", rsDummy!cBankID)
            rsMapping!cCheckNo = IIf(IsNull(rsDummy!cCheckNo), "", Trim(rsDummy!cCheckNo))

            rsMapping.MoveNext

            If rsMapping.EOF Then
                rsMapping.AddNew
            End If
        End If

        rsDummy.MoveNext
    Loop
    
    rsMapping.MoveFirst
    Do Until rsMapping.EOF
        If rsMapping.Status = (adRecNew) Or rsMapping.Status = (adRecModified) Then
            If IsNull(rsMapping!cInvNo) Then
                rsMapping.Delete
            ElseIf Trim(rsMapping!cInvNo) = "" Then
                rsMapping.Delete
            Else
                rsMapping.MoveNext
            End If
        Else
            rsMapping.MoveNext
        End If
    Loop
    
    GetChild

End Sub

'check mapping amount accuracy
Function CheckMappingOK() As Boolean
Dim n As Double
    
On Error Resume Next

    CheckMappingOK = True
    
    n = 0
    Set rs = New Recordset
    Set rs = rsMapping.Clone
    rs.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    
    If rs.RecordCount = 0 Then
        cmdMap_Click
        Exit Function
    End If
    
    Do Until rs.EOF
        n = n + IIf(IsNull(rs!nAmount), 0, rs!nAmount)
        rs.MoveNext
    Loop
    Set rs = Nothing
    
    If n <> CDbl(txtPayTotal) Then
        CheckMappingOK = False
        MsgBox "Check-Invoice mapping is unbalanced.", vbCritical, "ComUnion"
        Exit Function
    End If

End Function

'check mapping detail accuracy (checks only)
Function CheckMappingDetailOK() As Boolean
        
    CheckMappingDetailOK = True

    Set rs = New Recordset
    Set rs = rsMapping.Clone

    rs.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    
    If rs.RecordCount = 0 Then
        Set rs = Nothing
        Exit Function
    End If
    
    rs.Bookmark = dtgMap.Bookmark
    
    If Not CheckExisting(rs!cCheckNo, rs!cBankID, rs!cTranNo, rsPayment) Then
        MsgBox "Bank or check does not exist on payment details.", vbCritical, "ComUnion"
        CheckMappingDetailOK = False
    End If
    
    Set rs = Nothing
    
End Function

'check mapping accuracy (invoice only)
Function CheckMappingDetailInvOK() As Boolean
        
    CheckMappingDetailInvOK = True

    Set rs = New Recordset
    Set rs = rsMapping.Clone

    rs.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    
    If rs.RecordCount = 0 Then
        Set rs = Nothing
        Exit Function
    End If
    
    rs.Bookmark = dtgMap.Bookmark
    
    If Not InvoiceExisting(rs!cInvNo, rs!cTranNo, rsInvoice) Then
        MsgBox "Invoice number does not exist on payment details.", vbCritical, "ComUnion"
        CheckMappingDetailInvOK = False
    End If
    
    Set rs = Nothing
    
End Function

'Locking of dtgMap
Sub LockMapGrid(bval As Boolean)
    With dtgMap
        .Columns(0).Locked = bval
        .Columns(1).Locked = bval
        .Columns(2).Locked = bval
        .Columns(3).Locked = bval
    End With
End Sub

'Is check existing?
Function CheckExisting(CheckNo As String, Bank As String, TranNo As String, _
            rsExist As ADODB.Recordset, Optional FromDB As Boolean) As Boolean

Dim rsClone As New ADODB.Recordset

    CheckExisting = False
    
    If FromDB Then
        sSQL = "SELECT cCheckNo FROM CHECKS WHERE cCheckNo = '" & CheckNo & "' AND cBankID = '" & Bank & "' AND cCompanyID = '" & COID & "'"
        Set rs = New Recordset
        rs.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
        
        If rs.RecordCount <> 0 Then
            CheckExisting = True
            Set rs = Nothing
            Exit Function
        End If
        Set rs = Nothing
    End If
    
    Set rsClone = rsExist.Clone
    
    rsClone.Filter = "cCheckNo = '" & CheckNo & "' AND cBankID = '" & Bank & "' AND cTranNo = '" & TranNo & "'"
    
    If FromDB Then
        If rsClone.RecordCount > 1 Then
            CheckExisting = True
        End If
    Else
        If rsClone.RecordCount >= 1 Then
            CheckExisting = True
        End If
    End If
    
    Set rsClone = Nothing
    
End Function
   
'Is invoice existing in invoice detail?
Function InvoiceExisting(InvNo As String, TranNo As String, _
            rsExist As ADODB.Recordset) As Boolean

Dim rsClone As New ADODB.Recordset

    InvoiceExisting = False
    
    Set rsClone = rsExist.Clone
    
    rsClone.Filter = "cInvNo = '" & InvNo & "' AND cTranNo = '" & TranNo & "'"
    
    If rsClone.RecordCount >= 1 Then
        InvoiceExisting = True
    End If
    
    Set rsClone = Nothing
    
End Function

'Add checks to Checks Table
Sub AddToChecksTable()
Dim cmdToChecks As ADODB.Command
    
    Set cmdToChecks = New ADODB.Command
    With cmdToChecks
        .ActiveConnection = cn
        .CommandTimeout = 1000
        .CommandText = "SP_InsertChecksFromCollection"
        .CommandType = adCmdStoredProc
        .Parameters("@cCompanyID") = COID
        .Parameters("@cTranNo") = Trim(txtTranNo)
        .Execute
    End With
    Set cmdToChecks = Nothing

End Sub

'Add Details to EWT Table
Sub AddToEWTTable()
Dim cmdToEWT As ADODB.Command

    Set cmdToEWT = New ADODB.Command
    With cmdToEWT
        .ActiveConnection = cn
        .CommandTimeout = 1000
        .CommandText = "SP_InsertEWTFromCollection"
        .CommandType = adCmdStoredProc
        .Parameters("@cCompanyID") = COID
        .Parameters("@cTranNo") = Trim(txtTranNo)
        .Execute
    End With
    Set cmdToEWT = Nothing
End Sub



'Add etails to EVAT Table
Sub AddToEVATTable()
Dim cmdToEVAT As ADODB.Command

    Set cmdToEVAT = New ADODB.Command
    With cmdToEVAT
        .ActiveConnection = cn
        .CommandTimeout = 1000
        .CommandText = "SP_InsertEVATFromCollection"
        .CommandType = adCmdStoredProc
        .Parameters("@cCompanyID") = COID
        .Parameters("@cTranNo") = Trim(txtTranNo)
        .Execute
    End With
    Set cmdToEVAT = Nothing

End Sub

'Auto CM
Sub AutoCM()
Dim cmdAutoCM As ADODB.Command

    Set cmdAutoCM = New ADODB.Command
    With cmdAutoCM
        .ActiveConnection = cn
        .CommandTimeout = 1000
        .CommandText = "SP_InsertCMFromCollection"
        .CommandType = adCmdStoredProc
        .Parameters("@cCompanyID") = COID
        .Parameters("@cTranNo") = Trim(txtTranNo)
        .Execute
    End With
    Set cmdAutoCM = Nothing

End Sub


'Public Sub ShowForm(sTranNo As String)
'    If Mode = Find Then
'
'        OpenNewConnection connMapping
'        OpenNewConnection connOthers
'        OpenNewConnection connPayment
'        OpenNewConnection connInvoice
'        OpenNewConnection connHeader
'
'        Set rsHeader = Nothing
'        Set rsInvoice = Nothing
'        Set rsPayment = Nothing
'        Set rsOthers = Nothing
'        Set rsMapping = Nothing
'        Set rsHeader = New ADODB.Recordset
'        Set rsInvoice = New ADODB.Recordset
'        Set rsPayment = New ADODB.Recordset
'        Set rsOthers = New ADODB.Recordset
'        Set rsMapping = New ADODB.Recordset
'
'        OpenRecordsetWithCN rsMapping, "*", "PR_MAP", connMapping, "WHERE cTranNo = '" & Trim(sTranNo) & "'"
'        OpenRecordsetWithCN rsOthers, "*", "PR_O", connOthers, "WHERE cTranNo = '" & Trim(sTranNo) & "'"
'        OpenRecordsetWithCN rsPayment, "*", "PR_C", connPayment, "WHERE cTranNo = '" & Trim(sTranNo) & "'"
'        OpenRecordsetWithCN rsInvoice, "*", "PR_T", connInvoice, "WHERE cTranNo = '" & Trim(sTranNo) & "'"
'        OpenRecordsetWithCN rsHeader, "*", "PR", connHeader, "WHERE cTranNo = '" & Trim(sTranNo) & "'"
'
'        Set FrmName = Me
'        FormLocking True
'
'        If rsHeader.RecordCount = 0 Then
'            FormWaitHide
'            MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
'            RSZero
'            FormSearch True
'            SearchObj True
'            Mode = Find
'            Exit Sub
'        End If
'            SetDataSource
'            SetDataField
'            txtTranNo.BackColor = &HE0FFFF
'            Mode = Normal
'            oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True, True
'
'    End If
'End Sub
'
'
